Skip to content

Conversation

@bdeket
Copy link
Contributor

@bdeket bdeket commented Jul 29, 2020

add type for the optional arguments of 'in-fx/fl/extflvector' as in 'in-vector'

@bdeket
Copy link
Contributor Author

bdeket commented Jul 29, 2020

What would be a good test for this? Or how how to test this?

I see

[tc-e (for/list : (Listof Flonum) ([a (in-flvector (flvector 1.0 2.0))]) a)
             (-lst -Flonum)]

in the unit-test/typecheck-tests.rkt file. Best to add an extra test over there?

@sorawee
Copy link
Contributor

sorawee commented Jul 29, 2020

Since you are already adding a new test file, putting it there also makes sense. But really, I don't care where it's tested (though other people might, idk).

(check-equal? (for/list : (Listof Fixnum) ([i (in-fxvector (fxvector 1 2 3 4) 3 -1 -2)]) i)
(list 4.0 2.0))

(check-equal? (for/list : (Listof extflonum) ([i (in-extflvector (extflvector 1.0t0 2.0t0 3.0t0 4.0t0) 3 -1 -2)]) i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should be behind a (when (extflonum-available?) ...) check.

@bdeket
Copy link
Contributor Author

bdeket commented Jul 30, 2020

I see this fails for the cs branch, and looking into it, I don't understand why it succeeds on the bc branch.
the for expands to normalise-inputs, where the start/stop/step-indexes can be Nat/( U #f Nat)/Nat.

I don't know if typed-racket does something extra but if it is just using the racket implementation then I think the types for the indexes should be:
Nat/(U #f Nat -1)/(U Positive-Integer Negative-Integer)

I can change the test, to only count upwards in a for loop,
or look into changing the type for normalise-inputs...
And maybe also change the type for the step from Integer to (U Positive-Integer Negative-Integer) for in-vector and friends

@bdeket
Copy link
Contributor Author

bdeket commented Jan 27, 2021

@samth, I went ahead and changed the type for normalise-inputs to allow going backward through the vector.

@samth
Copy link
Member

samth commented Jan 27, 2021

Fantastic! I'll take a look and hopefully we can merge soon.

(check-equal? (sequence->list (in-fxvector (fxvector 1 2 3 4) 0 #f 2)) (list 1 3))
(check-equal? (for/list : (Listof Fixnum) ([i : Fixnum (ann (in-fxvector (fxvector 1 2 3 4) 3 -1 -2) (Sequenceof Fixnum))]) i)
(list 4 2))
;; I don't understand why this fails...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you say more about this failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping to be able to do:
(for/list : (Listof Fixnum) ([i (in-fxvector (fxvector 1 2 3 4) 3 -1 -2)]) i)
but without the annotation of (Sequenceof Fixnum) and Fixnum for i (both are necessary) The resulting list is seen as (Listof Integer)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a quick look at this failure. Seems it has something to do with unsafe-normalise-inputs and normalise-inputs. I might get back to some point later next week

@samth
Copy link
Member

samth commented Feb 2, 2021

I'm going to merge this now; we can try to make that example work with less annotation in the future.

@samth samth merged commit adcc138 into racket:master Feb 2, 2021
@bdeket bdeket deleted the in-flvector branch February 2, 2021 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants